package com.hongdee.crm.car.dao.impl;

import com.hongdee.base.basedao.impl.BaseDaoImpl;
import com.hongdee.crm.car.dao.ITCrmCarDao;
import com.hongdee.crm.car.entity.TCrmCar;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by My on 2017/2/22.
 */
@Service
public class TCrmCarDaoImpl extends BaseDaoImpl implements ITCrmCarDao {
    @Override
    public TCrmCar info(String id) throws Exception {
        String hql="from com.hongdee.crm.car.entity.TCrmCar where id=:id";
        Map map=new HashMap();
        map.put("id",id);
        return (TCrmCar) this.getHibernateDao().findEntityByHqlWithParams(hql,map);
    }

    /**
     * 根据VIN 公司ID 获得车主档案 信息
     * @param vin
     * @param companyId
     * @return
     * @throws Exception
     */
    @Override
    public com.hongdee.crm.car.entity.TCrmCar getCarInfo(String vin, String companyId) throws Exception {
        String hql="from com.hongdee.crm.car.entity.TCrmCar where vin=:vin and companyId=:companyId";
        Map<String,Object> params=new HashMap<>();
        params.put("vin",vin);
        params.put("companyId",companyId);
        return (com.hongdee.crm.car.entity.TCrmCar) this.getHibernateDao().findEntityByHqlWithParams(hql,params);
    }
}
